[go: nahoru, domu]

Skip to content

Commit

Permalink
Use a const string for error codes (#752)
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-ancell committed Jun 8, 2020
1 parent bae67ae commit 9f6628e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions plugins/file_chooser/gtk/file_chooser_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// See channel_controller.dart for documentation.
const char kChannelName[] = "flutter/filechooser";
const char kBadArgumentsError[] = "Bad Arguments";
const char kShowOpenPanelMethod[] = "FileChooser.Show.Open";
const char kShowSavePanelMethod[] = "FileChooser.Show.Save";
const char kInitialDirectoryKey[] = "initialDirectory";
Expand Down Expand Up @@ -74,7 +75,7 @@ static FlMethodResponse* show_dialog(FlFileChooserPlugin* self,
FlValue* properties) {
if (fl_value_get_type(properties) != FL_VALUE_TYPE_MAP) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad Arguments", "Argument map missing or malformed", nullptr));
kBadArgumentsError, "Argument map missing or malformed", nullptr));
}

const gchar* confirm_button_text = default_confirm_button_text;
Expand Down Expand Up @@ -120,7 +121,7 @@ static FlMethodResponse* show_dialog(FlFileChooserPlugin* self,
g_autoptr(GtkFileFilter) filter = file_type_to_filter(file_type);
if (filter == nullptr) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad Arguments", "Allowed file types malformed", nullptr));
kBadArgumentsError, "Allowed file types malformed", nullptr));
}
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
}
Expand Down
9 changes: 5 additions & 4 deletions plugins/window_size/gtk/window_size_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

// See window_size_channel.dart for documentation.
const char kChannelName[] = "flutter/windowsize";
const char kBadArgumentsError[] = "Bad Arguments";
const char kGetScreenListMethod[] = "getScreenList";
const char kGetWindowInfoMethod[] = "getWindowInfo";
const char kSetWindowFrameMethod[] = "setWindowFrame";
Expand Down Expand Up @@ -149,7 +150,7 @@ static FlMethodResponse* set_window_frame(FlWindowSizePlugin* self,
if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST ||
fl_value_get_length(args) != 4) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad arguments", "Expected 4-element list", nullptr));
kBadArgumentsError, "Expected 4-element list", nullptr));
}
double x = fl_value_get_float(fl_value_get_list_value(args, 0));
double y = fl_value_get_float(fl_value_get_list_value(args, 1));
Expand Down Expand Up @@ -177,7 +178,7 @@ static FlMethodResponse* set_window_minimum_size(FlWindowSizePlugin* self,
if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST ||
fl_value_get_length(args) != 2) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad arguments", "Expected 2-element list", nullptr));
kBadArgumentsError, "Expected 2-element list", nullptr));
}
double width = fl_value_get_float(fl_value_get_list_value(args, 0));
double height = fl_value_get_float(fl_value_get_list_value(args, 1));
Expand All @@ -198,7 +199,7 @@ static FlMethodResponse* set_window_maximum_size(FlWindowSizePlugin* self,
if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST ||
fl_value_get_length(args) != 2) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad arguments", "Expected 2-element list", nullptr));
kBadArgumentsError, "Expected 2-element list", nullptr));
}
double width = fl_value_get_float(fl_value_get_list_value(args, 0));
double height = fl_value_get_float(fl_value_get_list_value(args, 1));
Expand All @@ -216,7 +217,7 @@ static FlMethodResponse* set_window_title(FlWindowSizePlugin* self,
FlValue* args) {
if (fl_value_get_type(args) != FL_VALUE_TYPE_STRING) {
return FL_METHOD_RESPONSE(fl_method_error_response_new(
"Bad arguments", "Expected string", nullptr));
kBadArgumentsError, "Expected string", nullptr));
}

GtkWindow* window = get_window(self);
Expand Down

0 comments on commit 9f6628e

Please sign in to comment.